<template>
  <div>
    <div class="page login-page">
      <div class="container d-flex align-items-center">
        <div class="form-holder has-shadow">
          <div class="row">
            <!-- Logo & Information Panel-->
            <div class="col-lg-6">
              <div class="info d-flex align-items-center">
                <div class="content">
                  <div class="logo">
                    <h1>欢迎登录</h1>
                  </div>
                  <p>贝诺儿童健康管理系统</p>
                </div>
              </div>
            </div>
            <!-- Form Panel    -->
            <div class="col-lg-6 bg-white">
              <div class="form d-flex align-items-center">
                <div class="content">

                    <div class="form-group">
                      <input id="login-username" v-model.trim="userName" type="text" required data-msg="请输入用户名" placeholder="用户名" value="admin" class="input-material">
                    </div>
                    <div class="form-group">
                      <input id="login-password" type="password" v-model.trim="passWord" required data-msg="请输入密码" placeholder="密码" class="input-material">
                    </div>
                    <button  @click="doLogin" type="submit" class="btn btn-primary">登录</button>
                  <br />
                  <small >没有账号?</small><a href="#/register" class="signup" style="position: relative; bottom:24px;left:3px">&nbsp;注册</a>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  name: 'Children',
  data () {
    return {
      userName: '',
      passWord: ''
    }
  },
  methods: {
    doLogin () {
      this.$http.get('ChildLogin',
        {
          params: {
            username: this.userName,
            password: this.passWord
          }
        }).then(resp => {
        this.resp = JSON.stringify(resp.data)
        console.log(resp.data)
        if (resp.data.code === 0) {
          this.$router.replace({path: '/childmain'})
        } else if (resp.data.code === 5001) {
          confirm('用户名或密码错误登录被拒绝')
        }
      })
    }
  }
}
</script>

<style scoped="scoped">

</style>
